package multithread;

public class ThreadDemo7 {
    public static void main(String[] args) {
        Object locker = new Object();
        Thread t1 = new Thread(()->{
            synchronized (locker) {
                System.out.println("before t1 wait ");
                try {
                    locker.wait();
                } catch (InterruptedException e){
                    e.printStackTrace();
                }
                System.out.println("after t1 wait");
            }
        });
        Thread t2 = new Thread(()->{
            try {
                Thread.sleep(5000);
                synchronized (locker){
                    System.out.println("before t2 notify");
                    locker.notify();
                    System.out.println("after t2 notify");
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        t1.start();
        t2.start();
    }
}
